//
//  AsistentaViewController.m
//  RCA24
//
//  Created by Raul Pacurar on 2/5/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "AsistentaViewController.h"

// Properties

@implementation AsistentaViewController

// Properties

@synthesize firstButton;
@synthesize secondButton;
@synthesize thirdButton;
@synthesize fourthButton;
@synthesize fifthButton;
@synthesize sixthButton;

@synthesize blackScreenView;
@synthesize detailsView;
@synthesize detailsTitle;
@synthesize closeDetailsViewButton;
@synthesize firstDetailsScrollView;
@synthesize firstDetailsView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"Asistenta",@"Asistenta");
        self.tabBarItem.image = [UIImage imageNamed:@"asistenta"];
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self initializeScreen];
    
    UIImage * backgroundPattern = [UIImage imageNamed:@"bg-app.png"];
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:backgroundPattern]];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

// Destructor

- (void) dealloc
{
     [firstButton release];
     [secondButton release];
     [thirdButton release];
     [fourthButton release];
     [fifthButton release];
     [sixthButton release];
    
     [blackScreenView release];
     [detailsView release];
     [detailsTitle release];
     [closeDetailsViewButton release];
     [firstDetailsScrollView release];
     [firstDetailsView release];

    
    [super dealloc];
}

- (void) initializeScreen
{
    blackScreenView.alpha = 0;
    firstDetailsScrollView.contentSize = firstDetailsView.frame.size;
}

- (void) showDetailsViewAnimation
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    
    detailsView.transform = CGAffineTransformMakeTranslation(-320, 0);
}

- (void) hideDetailsViewAnimation
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    
    detailsView.transform = CGAffineTransformMakeTranslation(-0, 0);
}

- (IBAction) showDetailsView: (UIButton*) button
{
    detailsTitle.text = button.titleLabel.text;
    [blackScreenView setAlpha:0.8];
    [self showDetailsViewAnimation];
}

- (IBAction) hideDetailsView: (UIButton*) button
{
    [blackScreenView setAlpha:0];
    [self hideDetailsViewAnimation];
}

@end
